﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using University.Workshop.Model;
using University.Workshop.Presenters.AppointmentFolder;

namespace University.Workshop.WinApp
{
    public partial class UpdateAppointmentDate : Form , IUpdateAppointmentDate
    {
        private Appointment consult;
        private PresenterUpdateAppointmentDate presenter;
        public UpdateAppointmentDate()
        {
            consult = new Appointment();
            presenter = new PresenterUpdateAppointmentDate(this);
            InitializeComponent();
        }

        private void BuscarBtn_Click(object sender, EventArgs e)
        {
            SearchAppointmentToUpdate serachap = new SearchAppointmentToUpdate(consult);

            if (serachap.ShowDialog() == DialogResult.Cancel)
            {
                if (consult.Date != null)
                {
                    oldDate.Text = consult.Date.ToString();
                }
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            consult.Date = monthCalendar1.SelectionEnd.Date.ToShortDateString();
            presenter.UpdateAppointmentDate();
            MessageBox.Show("La fecha ha sido cambiada");
            this.Dispose();
        }

        public Appointment Apo
        {
            get
            {
                return consult;
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        private void button3_Click(object sender, EventArgs e)
        {
            DataAccess.AppointmentDataAccess.CancelAppointmentDate(Apo);
            MessageBox.Show("cita cancelada");
        }
    }
}
